package cn.kgc.fcm.springbootmybatisplusexample.config;

import cn.kgc.fcm.springbootmybatisplusexample.entity.Menu;
import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration  //表示该类是一个配置类
public class PageConfig {

    @Bean //将方法的放回置存入Spring容器
    public MybatisPlusInterceptor mybatisPlusInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        //添加拦截器，标记数据库为mysql
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));

        return interceptor;
    }

//    @Bean
//    public Page<Menu> page(){
//        Page<Menu> page = new Page<>();
//        page.setCurrent(1);
//        page.setSize(4);
//        return page;
//    }
}
